'    Copyright 2008 Jan Molnar <jan.molnar@abds.de>
'
'    This file is part of JCQ.

'    JCQ is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 2 of the License, or
'    (at your option) any later version.

'    JCQ is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with JCQ. If not, see <http://www.gnu.org/licenses/>.

''' <summary>
''' Represents a fixup for a ReadOnly Property which represents an object of type IList.
''' </summary>
Public Class ReadOnlyListPropertyFixUp
    Implements IFixUp

    Public Sub New(ByVal temporaryListId As Integer, ByVal targetList As IList)
        _TemporaryListId = temporaryListId
        _TargetList = targetList
    End Sub

    Private _TemporaryListId As Integer
    Public Property TemporaryListId() As Integer
        Get
            Return _TemporaryListId
        End Get
        Set(ByVal value As Integer)
            _TemporaryListId = value
        End Set
    End Property

    Private _TargetList As IList
    Public ReadOnly Property TargetList() As IList
        Get
            Return _TargetList
        End Get
    End Property

    Public Sub Execute(ByVal serializer As ISerializer) Implements IFixUp.Execute
        Dim temporaryList As IList = DirectCast(serializer.GetDeserializeObjectById(TemporaryListId), IList)

        For Each item In temporaryList
            _TargetList.Add(item)
        Next
    End Sub
End Class